<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="">
	<meta http-equiv="description" content="This is my page">

  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="" namespace="">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'新增问卷'}]"/>
    			<jsp:param name="width" value="50%"/>
    		</jsp:include>
    		<table cellspacing="1" cellpadding="3" bgcolor="#CCCCCC" width="100%">
    			<tr bgcolor="#FFFFFF">
    				<td width="20%" class="label" align="right">
    					问卷编号：
    				</td>
    				<td width="30%" align="left">
   						<s:textfield name="paper.paperCode" id="paperCode" cssStyle="width:90%;" maxlength="10"></s:textfield>
    				</td>
    				<td width="20%" class="label" align="right">
    					问卷名称：
    				</td>
    				<td width="30%" align="left">
    					<s:textfield name="paper.paperName" id="paperName" cssStyle="width:90%;" maxlength="20"></s:textfield>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td class="label" align="right">
    					半开放题行数：
    				</td>
    				<td align="left">
    					<s:textfield name="paper.halfQesRow" id="halfQesRow" cssStyle="width:90%;" maxlength="2"></s:textfield>
    				</td>
    				<td class="label" align="right">
    					全开放题行数：
    				</td>
    				<td align="left">
    					<s:textfield name="paper.fullQesRow" id="fullQesRow" cssStyle="width:90%;" maxlength="2"></s:textfield>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td class="label" align="right">
    					问卷时间：
    				</td>
    				<td align="left">
    					<input type="text" name="paper.paperTime" id="paperTime" style="width:90%;" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="<s:date name='paper.paperTime' format='yyyy-MM-dd' />" />
    				</td>
    				<td align="right">
    					
    				</td>
    				<td align="left">
    				
    				</td>
    			</tr>
    		</table>
    		
    		<table width="100%" cellspacing="0">
    			<tr>
    				<td align="center" valign="bottom" height="30">
    					<input type="button" value="保存" class="btn" onclick="saveThis()" />
    				</td>
    			</tr>
    		</table>
    	</s:form>
    </center>
    
    <script type="text/javascript">
    function saveThis()
    {
    	var paperCode = $('#paperCode');
    	var paperName = $('#paperName');
    	var halfQesRow = $('#halfQesRow');
    	var fullQesRow = $('#fullQesRow');
    	var paperTime = $('#paperTime');
    	if(!isNotNull(paperCode.val()))
    	{
    		showMsg('问卷编号不能为空。', function(){paperCode.focus();});
    		return;
    	}
    	if(!isNotNull(paperName.val()))
    	{
    		showMsg('问卷名称不能为空。', function(){paperName.focus();});
    		return;
    	}
    	if(checkInteger(halfQesRow) == false || parseInt(halfQesRow.val()) <= 0)
    	{
    		showMsg('半开放题行数必须为正整数。', function(){halfQesRow.focus();});
    		return;
    	}
    	if(checkInteger(fullQesRow) == false || parseInt(fullQesRow.val()) <= 0)
    	{
    		showMsg('全开放题行数必须为正整数。', function(){fullQesRow.focus();});
    		return;
    	}
    	if(!isNotNull(paperTime.val()))
    	{
    		showMsg('问卷时间不能为空。', function(){paperTime.focus();});
    		return;
    	}
    	ajaxAction('inner/qes/addPaper.action', 'post', 'frm', true, function(msg){
    		var obj = eval(msg);
    		if('hasCode' == obj[0].result)
    		{
    			showMsg('已存在该问卷编号，请重新输入。', function(){paperCode.focus();});
    		}
    		else
    		{
    			showMsg('保存成功。', function(){
    				window.opener.location.href = realPath + '/inner/qes/toUpdatePaper.action?paper.id=' + obj[0].id;
    				window.close();
    			});
    		}
    	});
    }
    </script>
  </body>
</html>
